#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int* countBits(int n, int* returnSize) {
    int* nums = malloc(sizeof(int) * (n + 1));
    *returnSize = n + 1;
    for (int i = 0; i <= n; i++)
    {
        int count = 0;
        int k = i;
        for (int j = 0; j < 32; j++)
        {
            if ((k >> j) & 1 == 1)
                count++;
        }
        nums[i] = count;
    }
    return nums;
}
